package scantask.containers.operationStanzas;

import scantask.containers.Coordinate;
import scantask.server.domainLayer.ControllerInterface;
import scantask.server.domainLayer.Exceptions.AddBenchmarkException;

public class AddBenchmarkStanza extends Stanza {
	
	private String _userName;
	private String _locationName;
	private Coordinate _coordinate;
	
	public AddBenchmarkStanza(String userName, String locationName, Coordinate coordinate) {
		this._userName = userName;
		this._locationName = locationName;
		this._coordinate = coordinate;
	}

	@Override
	public String perform(ControllerInterface controller) {
		try {
			controller.addBenchmark(this._userName, this._locationName, this._coordinate);
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending ACK to " + this._userName + " about add benchmark request");
			return "ACK";
		} catch (AddBenchmarkException e) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending exception to " + this._userName + " about add benchmark request");
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning(e.getErrorDescription());
			return this.parseToXML(e);
		}
	}

}
